package cn.org.xiaosheng.core.loadBalance;

import com.alibaba.nacos.api.naming.pojo.Instance;

import java.util.List;
import java.util.Random;

/**
 * @author XiaoSheng
 * @date 2024/8/20 下午10:17
 */
public class RandomRule implements LoadBalancer {

    private final Random random = new Random();

    /**
     * 随机获取实例
     * @param list
     * @return
     */
    @Override
    public Instance getInstance(List<Instance> list) {
        return list.get(random.nextInt(list.size()));
    }

}
